﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Strategy.Core.TradeTypes;

namespace Strategy.Core.TradeStreams.Indicators
{
    public class MACDSignalIndicatorStream : MACDIndicatorStream
    {
        public static string generateID(long sp, long lp, long ap) { return "MACDSignal " + sp + ", " + lp + ", " + ap; }
        public MACDSignalIndicatorStream(EMAIndicatorStream sema, EMAIndicatorStream lema, EMAIndicatorStream aema) : base(sema,lema)
        {
            EMAa = aema;
            values = new List<IndicatorValue>();
           
        }
        public long AveragePeriod { get { return EMAa.Period; } }
        protected EMAIndicatorStream EMAa = null;
        protected override double getCalculatedValue(QuoteData qd)
        {
            return EMAa.getByIndexFromEnd(0).Value * (EMAs.getByIndexFromEnd(0).Value - EMAl.getByIndexFromEnd(0).Value);
        }

        public override string getID()
        {
            return generateID(ShortPeriod, LongPeriod, AveragePeriod);
        }
    }
}
